package com.techstar.ats.codec.history.decoder;

import io.netty.buffer.ByteBuf;
import com.techstar.ats.codec.DateTimeCodec;
import com.techstar.ats.codec.Decoder;
import com.techstar.ats.codec.StringCodec;
import com.techstar.ats.dxp.history.F20Alarm;
import com.techstar.ats.type.AlarmType;
import com.techstar.ats.type.SiteType;

public enum F20AlarmDecoder implements Decoder<F20Alarm> {
	INSTANCE;

	public F20Alarm create() {
		return new F20Alarm();
	}

	public void decode(ByteBuf buf, F20Alarm value) {
		value.siteType = SiteType.valueOf(buf.readUnsignedByte());
		value.site = buf.readUnsignedShort();
		value.name = (new StringCodec(20)).get(buf);
		value.occTime = DateTimeCodec.INSTANCE.get(buf);
		value.type = AlarmType.valueOf(buf.readUnsignedShort());
		value.subType = buf.readUnsignedShort();
		int len = buf.readUnsignedShort();
		value.desc = (new StringCodec(len)).get(buf);
		value.ackSiteCode = buf.readUnsignedShort();
		value.ackSiteName = (new StringCodec(32)).get(buf);
		value.ackUserName = (new StringCodec(32)).get(buf);
		value.ackTime = DateTimeCodec.INSTANCE.get(buf);
	}
}
